package com.situ.mall.manager.mapper;

import com.situ.mall.manager.entity.Admin;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface AdminMapper {
    /**
     *
     * @param admin
     * @return
     */
    //int insert(Admin admin);

    /**
     *
     * @param id
     * @return
     */
    //int delete(Integer id);

    /**
     *
     * @param admin
     * @return
     */
    @Update({"<script>",
            "update admin",
            "<set>",
            "<if test='password != null and password.length>0'> password=#{password} ,</if>",
            "<if test='salt != null and salt.length>0'> salt=#{salt} ,</if>",
            "<if test='phone != null and phone.length>0'> phone=#{phone} ,</if>",
            "<if test='email != null and email.length>0'> email=#{email} ,</if>",
            "<if test='realname != null and realname.length>0'> realname=#{realname} ,</if>",
            "<if test='status != null'> status=#{status} ,</if>",
            "where id=#{id}",
            "</set>",
            "</script>",
    })
    int update(Admin admin);

    /**
     *
     * @param username
     * @return
     */
    @Select("select * from admin where username=#{username}")
    Admin selectByUsername(String username);

    /**
     *
     * @param id
     * @return
     */
    @Select("select * from admin where id=#{id}")
    Admin selectById(Integer id);

}
